
const fs = require('fs');

function content(src, statPath) {
  let fullPath = statPath + src;
  console.log('fullPath:', fullPath)
  if (fs.existsSync(fullPath)) {
    let stat = fs.statSync(fullPath);
    if (stat.isDirectory()) {
      return readDir(fullPath);
    } else {
      return fs.readFileSync(fullPath);
    }
  } else {
    return 'file not found'
  }

}


function readDir(src) {
  let files = fs.readdirSync(src);
  let result = ['<ul>'];
  files.forEach((item, index) => {
    result.push(`<li>${item}</li>`)
  })
  result.push('</ul>')
  return result.join(' ')
}

module.exports = content;

